#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn=1000, maxm=3000, maxp=10, inf=0x7ffffff;

int min(int a, int b) {
  return a<b ? a : b;
}

class Graph {
public:
  int n, m, ind[maxn+1], to[2*maxm+1], link[2*maxm+1], val[2*maxm+1];

  void addSide(int u, int v, int w) {
    m++;
    to[m] = v;
    val[m] = w;
    link[m] = ind[u];
    ind[u] = m;
  }

  void spfa(int dis[]) {
    static bool book[maxn+1];
    static int que[maxn+1];
    for (int i=1; i<=n; i++) {
      que[i] = i;
      book[i] = true;
    }
    for (int h=0, t=n; h!=t; ) {
      h = h%n+1;
      int x=que[h], y;
      book[x] = false;
      for (int i=ind[x]; i; i=link[i]) {
        y = to[i];
        if (dis[y]>dis[x]+val[i]) {
          dis[y] = dis[x]+val[i];
          if (!book[y]) {
            t = t%n+1;
            que[t] = y;
            book[y] = true;
          }
        }
      }
    }
  }
};

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static Graph g;
  static bool mark[1<<maxp];
  static int chan[maxp+1], imp[maxp+1], f[1<<maxp][maxn+1], ans[1<<maxp];
  int n, m, p;
  scanf("%d %d %d", &n, &m, &p);
  g.n = n;
  for (int i=1; i<=m; i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    g.addSide(u, v, w), g.addSide(v, u, w);
  }

  for (int i=1; i<=p; i++) {
    int c;
    scanf("%d %d", &c, imp+i);
    chan[c] |= 1<<(i-1);
  }
  for (int i=1; i<=p; i++) {
    mark[chan[i]] = true;
    for (int j=0; j<(1<<p); j++) {
      mark[j|chan[i]]|=mark[j];
    }
  }

  memset(f, 127, sizeof f);
  for (int i=1; i<=n; i++) {
    f[0][i] = 0;
  }
  for (int i=1; i<=p; i++) {
		f[1<<(i-1)][imp[i]] = 0;
	}
  for (int i=1; i<(1<<p); i++) {
		for (int x=1; x<=n; x++) {
			for (int j=i&(i-1); j!=i; j=(j-1)&i) {
				f[i][x] = min(f[i][x], f[j][x]+f[i-j][x]);
			}
		}

    g.spfa(f[i]);

    ans[i] = inf;
    if (mark[i]) {
      for (int j=1; j<=n; j++) {
        ans[i] = min(ans[i], f[i][j]);
      }
    }
  }

	for (int i=1; i<(1<<p); i++) {
		for (int j=1; j<(1<<p); j++) {
			ans[i|j] = min(ans[i|j], ans[i]+ans[j]);
		}
	}
  printf("%d", ans[(1<<p)-1]);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
